﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace SmartController.Convertors
{
    public class ReverseUInt16ValueConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (targetType != typeof(double))
                throw new InvalidOperationException("The target must be a ushort");

            return ushort.MaxValue - ((IConvertible)value).ToDouble(null);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
